package com.bw.lib_storage.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.bw.lib_storage.db.entity.History

/**
 * @author gjm
 * @date 2025/9/15
 * @description
 */

@Dao
interface HistoryDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(history: History)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertAll(vararg history: History)

    @Delete
    fun delete(history: History)

    @Update
    fun update(history: History)

    @Query("SELECT * FROM history")
    fun getAllHistory(): List<History>

    @Query("SELECT * FROM history WHERE title LIKE '%'+:title+'%'")
    fun findHistoryByTitle(title: String): List<History>
}